home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 February: Technology Seed / Mac Tech Seed Feb '97.toast / OpenDoc 1.2b2c1 / Implementation / Core / Prefs.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-13  |  7.3 KB  |  216 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        Prefs.h
  3.  
  4.     Contains:    Class definition for Preferences
  5.  
  6.     Owned by:    Caia Grisar 
  7.  
  8.     Copyright:    © 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <7>     10/4/96    EL        1343891: extra parameter for
  13.                                     read_nmap_resouces and read_nmap_buffer.
  14.          <6>     9/23/96    JP        1370876: Added parameter to ScanDirectory
  15.          <4>     6/22/96    EL        1356059: Add fPrevSizeRsrc and
  16.                                     DeletePrefFile
  17.          <3>     5/17/96    EL        #1263100: Add fProgressPictHdl and other
  18.                                     for progress bar in dialog.
  19.          <2>      5/3/96    EL        1257565: Make Read-nmap_Buffer params const
  20.                                     (from Jens).
  21.         <12>    10/20/95    CG        #1294494 GM:Info writing size info to the
  22.                                     wrong prefs file.
  23.         <11>     8/30/95    CG        #1255135 FB2:"Updating Part Editor
  24.                                     database" dlg comes up indefinitely
  25.                                     #1257569 FB3:Editor nmaps on read-only
  26.                                     volumes are not being cached.
  27.         <10>     8/25/95    JP        1272288:Added AETE routines & cacheFile
  28.                                     optimizations
  29.          <9>     6/22/95    jpa        Added fFoundBadAlias [1257556]
  30.          <8>     6/19/95    jpa        Added fScanningDialog and show/close
  31.                                     methods for it [1258142]
  32.          <7>      6/9/95    CG        #1203571 implemented  nmap caching
  33.                                     mechanism.
  34.          <6>     5/25/95    jpa        Store list of editor dirs [1240150]
  35.          <5>     5/18/95    CG        #1241621    BB: Need to implement Purge for
  36.                                     Binding subsystem objects.
  37.          <4>     5/17/95    TJ        Backed out changes from previous checkin.
  38.          <2>     4/24/95    eeh        1231707: fsspec param added to
  39.                                     Read_nmap_Buffer and Read_nmap_Resources
  40.          <1>     4/13/95    CG        first checked in
  41.         <14>     2/14/95    jpa        Changes to support reading Editors folders
  42.                                     on all disks. [1205141]
  43.         <13>      2/2/95    CG        Changed dirIDs to ODSLong and vRefNums to
  44.                                     ODSShort.
  45.         <12>     1/10/95    CG        Removed dead code.
  46.         <11>    12/13/94    CG        #1205141:Prefs code now looks in "Editors"
  47.                                     and "OpenDoc Libraries" folders for nmaps.
  48.         <10>    11/30/94    RR        #1188078 Use FSSpec instead of ODFileSpec
  49.          <9>     9/12/94    CG        #1157104: GetPartEditorNMAPs now looks in
  50.                                     same search path as CFM does for Part
  51.                                     Editor library files.  Temporary fix
  52.                                     removed.
  53.          <8>     8/25/94    CG        #1175107: Temporary fix to allow documents
  54.                                     to be opened from anywhere.
  55.          <7>     8/24/94    CG        #1181622: Updated ownership info.
  56.          <6>     7/29/94    CG        Changed some methods to return booleans
  57.                                     instead of throwing errors.
  58.          <5>     7/26/94    jpa        Don't inherit from ODObject!
  59.          <4>      7/1/94    CG        Renamed LocateASLMLibFiles to
  60.                                     LocatePartLibFiles.
  61.          <3>      7/1/94    CG        Change to LoadNMAPResource param list.
  62.          <2>     6/27/94    CG        Moved IsEditorLoaded to BindngH, removed
  63.                                     fEv.
  64.          <1>     6/14/94    CG        first checked in
  65.          <1>     5/27/94    CG        first checked in
  66.     To Do:
  67.     In Progress:
  68.         
  69. */
  70.  
  71. #ifndef _PREFS_
  72. #define _PREFS_
  73.  
  74. #ifndef _PLFMDEF_
  75. #include "PlfmDef.h"
  76. #endif
  77.  
  78. #ifndef _ODOBJ_
  79. #include "ODObject.xh"
  80. #endif
  81.  
  82. #ifndef _ODTYPES_
  83. #include "ODTypes.h"
  84. #endif
  85.  
  86. #ifndef __DIALOGS__
  87. #include <Dialogs.h>
  88. #endif
  89.  
  90. //=====================================================================================
  91. // Classes defined in this interface
  92. //=====================================================================================
  93.  
  94. class Preferences;
  95. class PrefsDirInfo;
  96. class PrefsDirInfoList;
  97.  
  98. //=====================================================================================
  99. // Classes used by this interface
  100. //=====================================================================================
  101.  
  102. class ODSession;
  103. class PlatformFile;
  104. class ODStorageUnitView;
  105. class LinkedList;
  106. class PrefsDirInfo;
  107.  
  108. //==============================================================================
  109. // Local Function Prototypes (from NamSpacM.cpp)
  110. //==============================================================================
  111.  
  112. //void ReadBytes(ODFileRefNum file, ODStorageUnitView* view,ODPtr bytes, ODULong* length);
  113. //ODULong ReadSize(ODFileRefNum file, ODStorageUnitView* view);
  114. enum {
  115.     kNestedFolder = 0,
  116.     kLibsFolder,
  117.     kSysEditorsFolder,
  118.     kRootEditorsFolder
  119. };
  120. typedef ODULong PrefsDirType;
  121.  
  122.  
  123. //=====================================================================================
  124. // Class Preferences
  125. //=====================================================================================
  126.  
  127. class Preferences
  128. {
  129. public:
  130.     
  131.     Preferences();
  132.     ~Preferences();
  133.     ODNVMethod void            InitPreferences(ODSession* session);
  134.                   
  135.     ODNVMethod ODSize        Purge(ODSize size);
  136.  
  137.     ODNVMethod ODBoolean    HaveEditorsFoldersChanged( );
  138.     ODNVMethod ODBoolean    ScanLibsAndEditors();
  139.     ODNVMethod void            UpdatePreferences();
  140.     ODNVMethod void            GetAETEs( ODSLong languageCode, AEDescList* aeteList);
  141.     ODNVMethod PlatformFile* GetPrefsFile();
  142.     
  143. private:
  144.     ODNVMethod void            CreatePrefsNameSpaces();
  145.     ODNVMethod ODSize        ClearEditorNameSpaces();
  146.     ODNVMethod void            GetOpenDocPrefs();
  147.     ODNVMethod void            GetOpenDoc_nmaps();
  148.     ODNVMethod void            ScanDirectory( ODSShort fldrVRefNum, ODSLong fldrDirID,
  149.                                             PlatformFile* cacheFile, AEDesc* aetes ); 
  150.     ODNVMethod void            ScanDirectoryTree(ODSShort fldrVRefNum, ODSLong fldrDirID,
  151.                                                       ODULong fldrModDate, PrefsDirType);
  152.     ODNVMethod void         VerifyCache(ODSShort fldrVRefNum, 
  153.                                           ODSLong fldrDirID, 
  154.                                           ODULong fldrModDate,
  155.                                           PrefsDirType type,
  156.                                           PlatformFile** cacheFile,
  157.                                           LinkedList** dirTreeList, 
  158.                                           ODBoolean* cacheIsValid);
  159.     ODNVMethod ODBoolean     LoadCachedDirList(PlatformFile* cacheFile,
  160.                                           ODSShort fldrVRefNum,
  161.                                           LinkedList** dirTreeList,
  162.                                           PrefsDirType type);
  163.     ODNVMethod ODBoolean    GetCacheFile(PlatformFile** cacheFile, ODSShort fldrVRefNum, 
  164.                                           ODSLong fldrDirID, ODULong fldrModDate );
  165.     ODNVMethod ODBoolean    LoadCachedRezData(PlatformFile* cacheFile, ODSShort vRefNum);
  166.     ODNVMethod void         TraverseDirectory( ODSShort fldrVRefNum, 
  167.                                           ODSLong fldrDirID, 
  168.                                           ODSShort depth, 
  169.                                           LinkedList* dirList );
  170.     ODNVMethod PrefsDirInfo* FindDirInfo( LinkedList* dirList, short vol, long dir );
  171.     ODNVMethod PrefsDirInfo* AddDirInfo( LinkedList* dirList, 
  172.                                         short vol, long dir, ODULong modDate,
  173.                                         ODSShort depth, PrefsDirType = kNestedFolder );
  174.     ODNVMethod    void        AddDirList(LinkedList* dirList);
  175.     ODNVMethod ODBoolean    Read_nmap_Resources(const FSSpec*,
  176.                                             PlatformFile* cacheFile,
  177.                                             ODBoolean loadable);
  178.     ODNVMethod ODBoolean    Read_nmap_Buffer( const void* buffer, ODSize bufferSize,
  179.                                             const FSSpec*, ODBoolean loadable );
  180.     ODNVMethod void            Write_nmap_Buffer( ODPtr buffer, ODSize bufferSize );
  181.     ODNVMethod ODBoolean    LocatePrefsFile();
  182.     ODNVMethod ODBoolean    LoadPreferences();
  183.     ODNVMethod ODBoolean    VerifyPrefsFileVersion();
  184.     ODNVMethod void            UpdatePrefsFileVersion();
  185.     ODNVMethod void            DeletePrefFile();
  186.     
  187.     ODNVMethod void            ShowScanningDialog( PlatformFile* fCacheFile );
  188.     ODNVMethod void            CloseScanningDialog( );
  189.     ODNVMethod void            CheckCancelScanningDialog( );
  190.  
  191. // Fields:
  192.     ODSession*             fSession;
  193.     ODNameSpaceManager *fNameSpaceMgr;
  194.     Str31                fLibsFolderName;
  195.     Str31                fEditorsFolderName;
  196.     PlatformFile*        fPrefsFile;
  197.     ODULong                fPrefsModDate;
  198.     LinkedList*            fDirList;
  199.     ODULong                fLastSynchedAt;
  200.     ODBoolean            fScanning;
  201.     ODBoolean            fFoundBadAlias;
  202.     PlatformFile*         fCacheFile;
  203.     ODHandle            fPrevSizeRsrc;
  204.     DialogPtr            fScanningDialog;
  205.     ODULong                fSleepTime;
  206.     ODHandle            fButtonControl;
  207.     ODUShort            fProgressPictIndex;
  208.     Rect                fProgressItemRect;
  209.     RgnHandle             fProgressItemRgn;
  210.     ODHandle            fProgresstPictHdl[4];
  211.     
  212.     friend class PrefsDirInfo;
  213. };
  214.  
  215. #endif // _PREFS_
  216.